package two_xia.ex9.Demo04;

import java.util.Iterator;

public class Client {
    public static void main(String[] args) {
        Class classRoom = new Class();
        classRoom.addStudent(new Student("老张", 28));
        classRoom.addStudent(new Student("但丁", 20));
        classRoom.addStudent(new Student("王五", 21));
        classRoom.addStudent(new Student("老赵", 20));

        Iterator<Student> iterator = classRoom.getStudentIterator();

        // 使用迭代器遍历学生
        while (iterator.hasNext()) {
            Student student = iterator.next();
            System.out.println(student);
        }
    }
}
